package com.dingpeikeji.quickdeer.modules.wx.trip;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dingpeikeji.quickdeer.core.common.persistence.Page;
import com.dingpeikeji.quickdeer.core.common.utils.DateUtils;
import com.dingpeikeji.quickdeer.core.modules.cupons.service.TCuponsService;
import com.dingpeikeji.quickdeer.core.modules.orders.entity.TOrders;
import com.dingpeikeji.quickdeer.core.modules.orders.service.TOrdersService;
import com.dingpeikeji.quickdeer.core.modules.site.entity.TSitedtl;
import com.dingpeikeji.quickdeer.core.modules.site.service.TSitedtlService;
import com.dingpeikeji.quickdeer.mobile.entity.CitySceneryInfo;
import com.dingpeikeji.quickdeer.mobile.entity.StayStandardInfo;
import com.dingpeikeji.quickdeer.mobile.entity.ThemeInfo;
import com.dingpeikeji.quickdeer.mobile.service.CitySceneryService;
import com.dingpeikeji.quickdeer.mobile.service.HotelStandardService;
import com.dingpeikeji.quickdeer.mobile.service.OrderService;
import com.dingpeikeji.quickdeer.mobile.service.StayStandardService;
import com.dingpeikeji.quickdeer.mobile.service.ThemeService;
import com.dingpeikeji.quickdeer.mobile.service.TransportWayService;
import com.dingpeikeji.quickdeer.modules.base.service.FrontUserService;
import com.dingpeikeji.quickdeer.modules.rentproduct.entity.ShareRentproduct;
import com.dingpeikeji.quickdeer.modules.rentproduct.entity.TCargotype;
import com.dingpeikeji.quickdeer.modules.rentproduct.entity.TRentgroup;
import com.dingpeikeji.quickdeer.modules.rentproduct.entity.TRentproduct;
import com.dingpeikeji.quickdeer.modules.rentproduct.service.FRentproductService;
import com.dingpeikeji.quickdeer.modules.rentproduct.service.RentproductOrderService;
import com.dingpeikeji.quickdeer.modules.rentproduct.service.ShareProductService;
import com.dingpeikeji.quickdeer.modules.rentproduct.service.TCargotypeService;
import com.dingpeikeji.quickdeer.modules.rentproduct.service.TRentgroupService;
import com.dingpeikeji.quickdeer.modules.rentproduct.service.TRentproductService;
import com.dingpeikeji.quickdeer.utils.BackResult;

@Controller
@RequestMapping("${wxPath}/trip")
public class WxTripController {
	@Autowired
	private ThemeService themeService;
	@Autowired
	private TSitedtlService tSitedtlService;
	@Autowired
	private HotelStandardService hotelStandardService;
	@Autowired
	private StayStandardService stayStandardService;
	@Autowired
	private CitySceneryService citySceneryService;
	@Autowired
	private TransportWayService transportWayService;

	@RequestMapping("toTripTravel")
	public String toShare(Model model,HttpServletRequest request,String tripstime,String travaltime,String childNum
			,String adultNum,String tripradio) {
		String departcitySitename = request.getParameter("departcity.sitename");
		String departcitySiteid = request.getParameter("departcity.siteid");
		String descitySitename = request.getParameter("destcity.sitename");
		String descitySiteid = request.getParameter("destcity.siteid");
		model.addAttribute("departcitySitename", departcitySitename);
		model.addAttribute("departcitySiteid", departcitySiteid);
		model.addAttribute("descitySitename", descitySitename);
		model.addAttribute("descitySiteid", descitySiteid);
		model.addAttribute("tripstime", tripstime);
		model.addAttribute("travaltime", travaltime);
		model.addAttribute("childNum", childNum);
		model.addAttribute("adultNum", adultNum);
		model.addAttribute("tripradio", tripradio);
		//游玩主题
		model.addAttribute("themeInfo", themeService.getThemeList());
		//交通方式
		model.addAttribute("TransportWayInfo", transportWayService.getTransportWayList());
		//必玩景点
		String[] siteids = request.getParameter("destcity.siteid").split(",");
		List<String> citycodeList = new ArrayList<String>();
		for (String id : siteids) {
			citycodeList.add(tSitedtlService.get(id).getCitycode());
		}
		List<CitySceneryInfo> scenery = new ArrayList<CitySceneryInfo>();
		CitySceneryInfo a = new CitySceneryInfo();
		a.setSceneryName("不限");
		a.setCitySceneryId("0");
		a.setCityCode("9999999");// 没有实际意义
		scenery.add(a);
		scenery.addAll(citySceneryService.getCitySceneryList((String[])citycodeList.toArray(new String[0])));
		model.addAttribute("sceneryList", scenery);
		//酒店标准
		model.addAttribute("stayStandard", stayStandardService.getStayStandardList());
		//价格
		if ("1".equals(tripradio)) {
			model.addAttribute("price", "60");
		}else{
			model.addAttribute("price", "40");
		}
		return "wx/modules/tripProduct/tripTravel";
	}

}
